<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>我的收藏</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style>
        .aui-bar-nav {
            /*padding: 0 11px 0 13px;
        box-sizing: border-box;*/
            top: 0;
            line-height: 2.25rem;
            background-color: #fff;
            color: #ffffff;
            border: none;
            background-size: 100% 1px;
            background-repeat: no-repeat;
            background-position: bottom;
            background-image: linear-gradient(0, #EEEEEE, #EEEEEE 50%, transparent 50%);
            background-image: -webkit-linear-gradient(90deg, #EEEEEE, #EEEEEE 50%, transparent 50%);
        }

        .aui-bar-nav .aui-btn .aui-iconfont {
            font-size: 0.9rem;
            line-height: 1.25rem;
            padding: 0;
            margin: 0;
            color: #000000;
        }

        .aui-bar-nav .aui-title {
            min-height: 2.25rem;
            position: absolute;
            margin: 0;
            text-align: center;
            white-space: nowrap;
            right: 5rem;
            left: 5rem;
            width: auto;
            overflow: hidden;
            text-overflow: ellipsis;
            z-index: 2;
            color: #333333;
            font-size: 17px;
            /*font-weight: bolder;*/
        }

        .aui-btn span {
            width: 22px;
            height: 22px;
        }

        .aui-btn span img {
            width: 22px;
            height: 22px;
        }

        .aui-bar-nav .aui-pull-right {
            padding: 0 11px;
            font-size: 0.8rem;
            font-weight: 400;
            z-index: 2;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            -webkit-align-items: center;
            align-items: center;
        }

        button,
        .aui-btn {
            position: relative;
            display: inline-block;
            font-size: 0.7rem;
            font-weight: 400;
            font-family: inherit;
            text-decoration: none;
            text-align: center;
            margin: 0;
            background: #EEEEEE;
            padding: 0 15px!important;
            height: 1.5rem;
            line-height: 1.5rem;
            border-radius: 0.2rem;
            white-space: nowrap;
            text-overflow: ellipsis;
            vertical-align: middle;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -webkit-user-select: none;
            user-select: none;
        }

        .aui-pull-right {
            font-size: 15px;
            color: #222222!important;
            text-align: right;
        }

        .footer_inner {
            width: 100%;
            padding: 0 15px;
            display: flex;
            justify-content: space-between;
            overflow: hidden;
        }

        .footer_inner_l {
            display: flex;
        }

        .footer_inner_r {
            width: 44px;
            height: 20px;
            background: #FFFFFF;
            border: 1px solid #CC0004;
            border-radius: 10px;
            font-size: 12px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #CC0004;
            line-height: 20px;
            margin-top: 12px;
        }

        .selected {
            width: 15px;
            height: 15px;
            margin-top: 15px;
        }

        .aui-checkbox {
            border-radius: 50%;
        }

        .aui-radio,
        .aui-checkbox {
            width: 15px;
            height: 15px;
            /*background-color: #ffffff;*/
            border: solid 1px #dddddd;
            -webkit-border-radius: 0.6rem;
            border-radius: 0.6rem;
            /*font-size: 0.8rem;*/
            margin: 0;
            padding: 0;
            position: relative;
            display: inline-block;
            vertical-align: top;
            cursor: default;
            -webkit-appearance: none;
            -webkit-user-select: none;
            user-select: none;
            -webkit-transition: background-color ease 0.1s;
            transition: background-color ease 0.1s;
        }

        .footer_inner_l .agree_text {
            font-size: 13px;
            color: #999999;
            line-height: 44px;
            height: 44px;
            margin-left: 5px;
        }

        .aui-radio:checked,
        .aui-radio.aui-checked,
        .aui-checkbox:checked,
        .aui-checkbox.aui-checked {
            background: url(../../image/select.png) no-repeat;
            background-size: 15px 15px;
            border: none;
            /*background-color: #49A76D;
          border: solid 1px #49A76D;
          text-align: center;
          background-clip: padding-box;
          background: -moz-linear-gradient(top, #49A76D 0%, #97E3B4 100%);*/
            /*background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #000000), color-stop(100%, #ffffff));
          background: -webkit-linear-gradient(top, #000000 0%, #ffffff 100%);
          background: -o-linear-gradient(top, #000000 0%, #ffffff 100%);
          background: -ms-linear-gradient(top, #000000 0%, #ffffff 100%);
          background: linear-gradient(to bottom, #000000 0%, #ffffff 100%);
          filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#ffffff', GradientType=0);*/
        }

        .aui-radio:checked:before,
        .aui-radio.aui-checked:before,
        .aui-checkbox:checked:before,
        .aui-checkbox.aui-checked:before,
        .aui-radio:checked:after,
        .aui-radio.aui-checked:after,
        .aui-checkbox:checked:after,
        .aui-checkbox.aui-checked:after {
            content: '';
            width: 0rem!important;
            height: 0rem!important;
            position: absolute;
            top: 0!important;
            left: 0!important;
            margin-left: 0rem!important;
            margin-top: 0rem!important;
            background: transparent;
            border: 0px solid #ffffff !important;
            border-top: none;
            border-right: none;
            z-index: 2;
            -webkit-border-radius: 0;
            border-radius: 0;
            -webkit-transform: rotate(-45deg);
            transform: rotate(-45deg);
        }
    </style>
</head>

<body>
    <div id="app">
        <header class="aui-bar aui-bar-nav" id="header">
            <a class="aui-pull-left aui-btn" tapmode onclick="closeWin()">
                <span>
               <img src="../../image/back_arrow.png" alt="">
            </span>
            </a>
            <div class="aui-title">我的收藏</div>
            <a class="aui-pull-right aui-btn" @click="manager()" v-if='ismanager'>管理</a>
        </header>
        <footer class="aui-bar aui-bar-tab" id="footer">
            <div class="footer_inner">
                <div class="footer_inner_l">
                    <div class="selected">
                        <input class="aui-checkbox" type="checkbox" name='demo1' value="1" v-model="checked" @input='change()'>
                    </div>
                    <div class="agree_text">全选</div>
                </div>
                <div class="footer_inner_r" @click='deleteHandel()'>删除</div>
            </div>
        </footer>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/cling.js"></script>
<script type="text/javascript">
    apiready = function() {
        var header = $api.byId('header');
        var headerH = $api.fixStatusBar(header);
        vm.init();

        api.addEventListener({
            name: 'backpage'
        }, function(ret, err) {
            if (ret) {
                //  alert(JSON.stringify(ret))
                vm.init();
            }
        });


        api.addEventListener({
            name: 'refreshCollection'
        }, function(ret, err) {
            if (ret) {
                vm.ismanager = false;
                var header = $api.byId('header');
                var headerH = $api.fixStatusBar(header);
                var rect = {
                    marginTop: headerH,
                    marginBottom: api.safeArea.bottom, // main页面距离win底部的高度
                    w: 'auto'
                }
                api.setFrameGroupAttr({
                    name: 'CollectionGroup',
                    rect: rect,
                });
                api.setFrameGroupIndex({
                    name: 'CollectionGroup',
                    index: 2
                });
            }
        });

        api.addEventListener({
            name: 'setAllcheck'
        }, function(ret, err) {
            if (ret) {
                vm.checked = true;
            }
        });
        api.addEventListener({
            name: 'setNoAllcheck'
        }, function(ret, err) {
            if (ret) {
                vm.checked = false;
            }
        });



    }

    var vm = new Vue({
        el: "#app",
        data: {
            ismanager: false,
            checked: false
        },
        methods: {
            init: function() {
                // alert(111)
                vm.ismanager = true;
                var header = $api.byId('header');
                var headerH = $api.fixStatusBar(header);
                api.openFrameGroup({
                    name: 'CollectionGroup',
                    background: '#FAF9F9',
                    scrollEnabled: false,
                    rect: {
                        marginTop: headerH,
                        marginBottom: api.safeArea.bottom, // main页面距离win底部的高度
                        w: 'auto'
                    },
                    index: 0,
                    frames: [{
                        name: 'my_collection_frm',
                        url: './my_collection_frm.html',
                        bounces: true,
                        bgColor: '#FAF9F9'
                    }, {
                        name: 'my_collection_frame_',
                        url: './my_collection_frame_.html',
                        bounces: true,
                        bgColor: '#FAF9F9'
                    }, {
                        name: 'my_collection_frame',
                        url: 'my_collection_frame.html',
                        bounces: true,
                        bgColor: '#FAF9F9'
                    }]
                }, function(ret, err) {
                    if (ret) {

                    }
                });
            },
            manager: function() {
                var header = $api.byId('header');
                var headerH = $api.fixStatusBar(header);
                var footer = $api.byId('footer');
                $api.fixTabBar($api.byId('footer'));
                footerH = $api.offset(footer).h;
                var rect = {
                    marginTop: headerH,
                    marginBottom: footerH + api.safeArea.bottom, // main页面距离win底部的高度
                    w: 'auto'
                }
                api.setFrameGroupAttr({
                    name: 'CollectionGroup',
                    rect: rect,
                });
                api.setFrameGroupIndex({
                    name: 'CollectionGroup',
                    index: 1
                });
            },
            change: function() {
                console.log(!vm.checked);
                if (!vm.checked) {
                    var jsfun = 'vm.allChecked();';
                    api.execScript({
                        frameName: 'my_collection_frame_',
                        script: jsfun
                    });
                } else {
                    var jsfun = 'vm.NoSelect();';
                    api.execScript({
                        frameName: 'my_collection_frame_',
                        script: jsfun
                    });
                }
            },
            deleteHandel: function() {
                console.log(vm.checked);
                if (vm.checked) {
                    api.sendEvent({
                        name: 'refreshCollection'
                    });
                } else {

                }
                var jsfun = 'vm.delete();';
                api.execScript({
                    frameName: 'my_collection_frame_',
                    script: jsfun
                });
            }
        }
    })

    function closeWin() {
        cl.closeWin({
            name: 'my_collection'
        })

    }

    function manager() {
        // cl.closeFrame({
        //     name: 'my_collection_frame'
        // })
        // cl.openFrame({
        //     name: './my_collection_frame_',
        //     header: header,
        //     footer: footer,
        //     bounces: true,
        //     bgColor: "#FAF9F9"
        // });
    }
</script>

</html>
